home *** CD-ROM | disk | FTP | other *** search
- Option Explicit
-
- Global NewLine As String * 2
- Global tabs As String * 1
-
- Type TreeListType
- Caption As String
- Number As Long
- BranchType As Integer
- LeafDeep As Integer
- ShowBranches As Integer
- End Type
- Dim TreeList() As TreeListType
- 'Branchtypes
- Const btRoot = 1
- Const btBranch = 2
- Const btLeaf = 3
- 'AddLine
- Global Const alAdd = 1
- Global Const alCreate = 2
- Global Const alNew = 3
-
- Sub tlAddLine (MyString As String, MyDeep As Integer, MyFlag As Integer, MyList As ListBox)
- Dim temp$
- Static MyText$
- temp$ = String(MyDeep, Chr$(9))
- Select Case MyFlag
- Case alNew
- MyText$ = MyString
- Case alAdd
- MyText$ = MyText$ + NewLine + temp$ + MyString
- Case alCreate
- MyText$ = MyText$ + NewLine + temp$ + MyString
- tlCreate MyList, MyText$
- Case Else
- End Select
- End Sub
-
- Sub tlCreate (MyList As ListBox, MyText As String)
- Dim cr As Integer, bd As Integer, b As Integer
- Dim i As Long, c As Long
- Dim temp$, branch$
- temp$ = MyText
- MyList.Clear
- Do
- cr = InStr(temp$, NewLine)
- If cr Then
- temp$ = Right$(temp$, Len(temp$) - cr)
- c = c + 1
- End If
- Loop While cr
- ReDim TreeList(c)
- temp$ = MyText
- For i = 0 To c
- cr = InStr(temp$, NewLine)
- If cr Then
- branch$ = Left$(temp$, cr - 1)
- temp$ = Right$(temp$, Len(temp$) - cr)
- Else
- branch$ = temp$
- End If
- If Len(branch$) Then
- If Asc(branch$) = 10 Then branch$ = Right$(branch$, Len(branch$) - 1)
- bd = 0
- TreeList(i).Caption = branch$
- TreeList(i).Number = i
- TreeList(i).ShowBranches = False
- Do
- b = InStr(branch$, tabs)
- If b Then
- bd = bd + 1
- branch$ = Right$(branch$, Len(branch$) - b)
- End If
- Loop While b
- If bd = 0 Then
- TreeList(i).BranchType = btRoot
- MyList.AddItem TreeList(i).Caption
- MyList.ItemData(MyList.NewIndex) = i
- Else
- TreeList(i).BranchType = btLeaf
- End If
- TreeList(i).LeafDeep = bd
- If i > 0 Then
- If TreeList(i).LeafDeep > TreeList(i - 1).LeafDeep Then
- TreeList(i - 1).BranchType = btBranch
- End If
- End If
- End If
- Next i
- TreeList(i - 1).BranchType = btLeaf
- End Sub
-
- Function tlDblClick (MyList As ListBox) As Integer
- Dim ti As Long, b As Long, li As Long, i As Long, sbi As Integer
- tlDblClick = False
- li = MyList.ListIndex
- ti = MyList.ItemData(li)
- Select Case TreeList(ti).BranchType
- Case btRoot, btBranch
- If TreeList(ti).ShowBranches Then
- li = li + 1
- For i = li To MyList.ListCount - 1
- sbi = MyList.ItemData(li)
- If TreeList(ti).LeafDeep < TreeList(sbi).LeafDeep Then
- TreeList(sbi).ShowBranches = False
- MyList.RemoveItem li
- Else
- Exit For
- End If
- Next i
- TreeList(ti).ShowBranches = False
- Else
- b = ti + 1
- For i = b To UBound(TreeList)
- If TreeList(ti).LeafDeep < TreeList(i).LeafDeep Then
- If TreeList(ti).LeafDeep + 1 = TreeList(i).LeafDeep Then
- li = li + 1
- MyList.AddItem TreeList(i).Caption, li
- MyList.ItemData(MyList.NewIndex) = i
- End If
- Else
- Exit For
- End If
- Next i
- TreeList(ti).ShowBranches = True
- End If
- Case btLeaf
- tlDblClick = True
- Case Else
- End Select
- End Function
-
-